package com.mo.ld.activity.interactive

import android.Manifest
import android.annotation.SuppressLint
import android.os.Bundle
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.dylanc.longan.activity
import com.hjq.permissions.OnPermissionCallback
import com.hjq.permissions.XXPermissions
import com.mo.ld.R
import com.mo.ld.base.BBaseListActivity
import com.mo.ld.bean.ActionBean
import com.mo.lib.utils.*
import com.mo.lib.view.recyclerview.getAdapterQuick
import com.mo.lib.view.recyclerview.layoutG

/**
 * @ author：mo
 * @ data：2022/3/25:14:57
 * @ 功能：
 */
class BengsActivity : BBaseListActivity<ActionBean>() {
    override fun initView(savedInstanceState: Bundle?) {
        super.initView(savedInstanceState)
        viewBinding?.krvBaseList?.layoutG(3)
    }

    override fun getList(page: Int) {
    }

    override fun getMore(page: Int) {
    }

    override fun creatAdaper(): BaseQuickAdapter<ActionBean, BaseViewHolder> {
        return getAdapterQuick(R.layout.item_main,
            arrayListOf(
                ActionBean("跳设置软件自启动") {
                    toAutoStart()
                },
                ActionBean("跳应用市场") {
                    toMarket()
                },
                ActionBean("应用信息") {
                    toAppSetting()
                },
                ActionBean("应用通知") {
                    toSettingNotification()
                },
                ActionBean("跳拨号") {
                    toDial()
                },
                ActionBean("打电话") {
                    XXPermissions.with(activity).permission(Manifest.permission.CALL_PHONE).request(object : OnPermissionCallback {
                        @SuppressLint("MissingPermission") override fun onGranted(permissions: MutableList<String>?, all: Boolean) {
                            toCall(15100299848.toString())
                        }

                        override fun onDenied(permissions: MutableList<String>?, never: Boolean) {
                            super.onDenied(permissions, never)
                            showToast("没权限")
                        }
                    })
                },
                ActionBean("跳浏览器") {
                    toBrowser("www.baidu.com")
                },
                ActionBean("跳联系人") {
                    toContacts()
                },
                ActionBean("跳Wifi设置") {
                    toSettingWifi()
                },
                ActionBean("跳卸载应用") {
                    toUninstallApp()
                },
                ActionBean("跳选择音频") {
                    toPickAudio()
                },
                ActionBean("跳选择视频") {
                    toPickVideo()
                },
                ActionBean("跳应用管理列表") {
                    toAppsManage()
                },
                ActionBean("跳无障碍服务设置") {
                    toSettingAccessibility()
                },
                ActionBean("跳网络设置") {
                    toSettingNet()
                },
                ActionBean("跳桌面主页") {
                    toHome()
                },
                ActionBean("重启当前应用") {
                    toRestartApp()
                },
                ActionBean("跳GPS设置") {
                    toSettingGps()
                },
            ),
            block = { holder, item ->
                holder.setText(R.id.tv_item_main, item.name).itemView.setClick {
                    item.event.invoke()
                }
            })

    }


}